package com.wlzg.collectiontool.db

import androidx.room.*
import androidx.room.ForeignKey.CASCADE


@Entity(tableName = "users")
data class Usert(
    @PrimaryKey(autoGenerate = true) var userId: Long
)

@Entity
data class User(
    @PrimaryKey val userId: Long,
    val name: String,
    val age: Int
)

@Entity(
    foreignKeys = [ForeignKey(
        entity = User::class,
        parentColumns = ["userId"],
        childColumns = ["userCreatorId"],
        onDelete = CASCADE
    )]
)
data class Playlist(
    @PrimaryKey val playlistId: Long,
    val userCreatorId: Long,
    val playlistName: String
)

data class UserWithPlaylists(
    @Embedded val user: User,
    @Relation(
        parentColumn = "userId",
        entityColumn = "userCreatorId"
    )
    val playlists: List<Playlist>,

)


